<form name="form_shop" id="form_shop" action="shop.manage.php?action=modi" method="POST" enctype="multipart/form-data">
<input type="hidden" name="area_id" id="area_id" value="<tpl> $shop_array.shop_area_id </tpl>" />	
<input type="hidden" name="hideShopId" id="hideShopId" value="<tpl> $shop_array.shop_id </tpl>" />	
<table width="680" class="from_table">
  <tr>
    <th class="th1"><tpl> $langSysName </tpl>：</th>
    <td width="500" class="td1">
    	<input type="text" name="txtShopName" id="txtShopName" value="<tpl> $shop_array.shop_name </tpl>" />
    	<label style="display:none" for="txtShopName" class="wrong" metaDone="true" generated="true"></label></td>
  </tr>
  <tr>
    <th class="th1"><tpl> $langSysShopHost </tpl>：</th>
    <td width="500" class="td1"><tpl> $shop_array.login_name </tpl></td>
  </tr>
  <tr>
  	<th class="th1"><tpl> $langSysShopLogo </tpl>：</th>
  	<td width="120" class="td1">
      <tpl> if $shop_array.shop_pic != "" </tpl> 
	  	<img height="60" width="60" src="<tpl> $site_url </tpl>/<tpl> $shop_array.shop_pic|default:'images/storepic_default.gif' </tpl>" /> <a href="javascript:;" onclick="ajax_delLogo('<tpl> $shop_array.shop_id </tpl>')"><tpl> $langCdele </tpl></a> 
	   <tpl> else </tpl>
        <input name="fileShopLogo" type="file" id="fileShopLogo" />
      <tpl> /if </tpl>  
		 <br/><tpl> $langSysShopLogoExplain </tpl> 	      	
  	</td>
  </tr>
  <tr>
  	<th class="th1"><tpl> $langSysShopBanner </tpl>：</th>
  	<td width="120" class="td1">
          <tpl> if $shop_array.shop_banner_pic != "" </tpl> 
		  	<img height="60" width="60" src="<tpl> $site_url </tpl>/<tpl> $shop_array.shop_banner_pic|default:'images/storepic_default.gif' </tpl>" /> <a href="javascript:;" onclick="ajax_delBanner('<tpl> $shop_array.shop_id </tpl>')"><tpl> $langCdele </tpl></a> 
		   <tpl> else </tpl>
            <input name="fileShopBanner" type="file" id="fileShopBanner" />
          <tpl> /if </tpl>
		 <br/><tpl> $langSysShopBannerExplain </tpl>  	
  	</td>
  </tr>  
  <tr>
    <th class="th1"><tpl> $langSysSClass </tpl>：</th>
    <td width="500" class="td1">
        <select name="slcShopClass" class="new_input" style="width:230px">
	  		<tpl> foreach from=$shop_select_category item=one </tpl>
				<option <tpl> if $one.class_id eq $shop_array.shop_class </tpl>selected="selected"<tpl> /if </tpl> value="<tpl> $one.class_id </tpl>"><tpl> $one.class_name </tpl></option>
					<tpl> foreach from=$one.child item=two </tpl>
					<option <tpl> if $two.class_id eq $shop_array.shop_class </tpl>selected="selected"<tpl> /if </tpl> value="<tpl> $two.class_id </tpl>">&nbsp;&nbsp;&nbsp;&nbsp;<tpl> $two.class_name </tpl></option>
					<tpl> /foreach </tpl>
			<tpl> /foreach </tpl>
	  	</select>    	
    </td>
  </tr>
  <tr>
    <th class="th1"><tpl> $langSysShopBound </tpl>：</th>
    <td width="500" class="td1">
    	<textarea name="txtSaleRange" id="txtSaleRange" rows="3" cols="30"><tpl> $shop_array.sale_range </tpl></textarea>
    </td>
  </tr>
  <tr>
  	<th class="th1"><tpl> $langSysShopLocus </tpl>：</th>
	<td class="td1">
      	<select id="c1" class="searchformselect" name="c1" style="width: 120px">
			<option valus="" selected></option>
			<tpl> foreach item = parent from = $area_array </tpl>
			<option <tpl> if $sel_area[0].area_id eq $parent.area_id </tpl>selected="selected"<tpl> /if  </tpl> value="<tpl>$parent.area_id</tpl>||<tpl>$parent.is_parent</tpl>"><tpl> $parent.area_name </tpl></option>
			<tpl> /foreach </tpl>
		</select>
		<select class="searchformselect" id="c2" style="width: 120px" name="c2">
			<option valus="<tpl> $sel_area[1].area_id </tpl>" selected><tpl> $sel_area[1].area_name </tpl></option>
		</select>
		<select class="searchformselect" id="c3" style="width: 120px" name="c3">
			<option valus="<tpl> $sel_area[2].area_id </tpl>" selected><tpl> $sel_area[2].area_name </tpl></option>
		</select>
		<select class="searchformselect" id="c4" style="width: 120px" name="c4">
			<option valus="<tpl> $sel_area[3].area_id </tpl>" selected><tpl> $sel_area[3].area_name </tpl></option>
		</select>
      	<label style="display:none" for="area_id" class="wrong" metaDone="true" generated="true"></label>
	</td>
  </tr>
  <tr>
    <th class="th1"><tpl> $langSysShopIntro </tpl>：</th>
    <td colspan="2" class="td1">
    	<textarea name="txtShopIntro" id="txtShopIntro" rows="3" cols="30"><tpl> $shop_array.shop_intro</tpl></textarea>
    </td>
  </tr>
  <tr>
    <th class="th1"><tpl> $langSysShopAffiche </tpl>：</th>
    <td class="td1" colspan="2">
    	<textarea name="txtProclamation" id="txtProclamation" rows="3" cols="30"><tpl> $shop_array.proclamation</tpl></textarea>
    </td>
  </tr>
  <tr>
    <th class="th1"><tpl> $langSysShopTime </tpl>：</th>
    <td class="td1" colspan="2"><tpl> $shop_array.practice_time </tpl></td>
  </tr>
  <tr>
    <th class="th1"><tpl> $langSysSEstate </tpl>：</th>
    <td class="td1" colspan="2"><tpl> $shop_array.open_state </tpl></td>
  </tr>
  <tr>
    <td >	</td>
    <td colspan="2" >
		<span class="btn_left">
	<input type="submit" value="<tpl> $langSysShopModi </tpl>" class="btn_submit"/></span>
	<span class="btn_left">
	<input type="button" id="return" name="return" value="<tpl> $langSysShopReturn </tpl>" class="btn_submit"/>
	</span>	</td>
  </tr>
</table>
</form>
<script language="javascript">
$(document).ready(function() {
	//返回列表
	$("#return").click(function(){
		ShowDiv = "result_content";
		getPageContent("shop.manage.php?action=ajax_list&curpage=<tpl>$curpage</tpl>");
	});
	
	var options = {
		beforeSubmit:  function(){showLoading(showSaveText);},
		success:       function(msg){
			hideLoading();
			showMessage(msg.message);
			if(msg.type == '1'){
				ShowDiv = "result_content";
				getPageContent("shop.manage.php?action=ajax_list&curpage=<tpl>$curpage</tpl>");
			}
		},

		type:      'post',
		dataType:  'json'
	};
	
	//对添加表单做的验证定义
	$('#form_shop').validate({
		errorClass: "wrong",
		rules: {
			txtShopName: {required:true},
			area_id: {required:true}
		},
		messages: {
			txtShopName: {required: "<tpl> $langSysShopCheckShopname </tpl>"},
			area_id: {required: "<tpl> $langSysShopCheckArea </tpl>"}
		},
		submitHandler: function() {
			$('#form_shop').ajaxSubmit(options);
		}
	});
});
//删除店标
function ajax_delLogo(id){
	$.ajax({
		url: "shop.manage.php",
		data: 'action=dellogo&shop_id='+id,
		type:'post',
		dataType:"json",
		beforeSubmit:  showLoading(showText),
		success: function(msg){
			hideLoading();
			showMessage(msg.message,msg.type);
			if(msg.type == 1){
				ShowDiv = "result_content";
				getPageContent("shop.manage.php?action=show&curpage=<tpl>$curpage</tpl>&shopid="+id);
			}
		}
	});
	return false;
}
//删除banner
function ajax_delBanner(id){
	$.ajax({
		url: "shop.manage.php",
		data: 'action=delbanner&shop_id='+id,
		type:'post',
		dataType:"json",
		beforeSubmit:  showLoading(showText),
		success: function(msg){
			hideLoading();
			showMessage(msg.message,msg.type);
			if(msg.type == 1){
				ShowDiv = "result_content";
				getPageContent("shop.manage.php?action=show&curpage=<tpl>$curpage</tpl>&shopid="+id);
			}
		}
	});
	return false;
}
//地区选择
function tonext(whos) {
	$(whos).change(
		function(){
			var valarray=$(this).val().split('||');	
			$('#area_id').val(valarray[0]);
			if (valarray[1]=='1') {
				$(this).next().attr('disabled','true').html('<option value="" selected="selected"><tpl> $langCDataToLoading </tpl></option>');
				$.get(
					'../home/tohtml.php',
					{action:'get_area',id:valarray[0],random_number:Math.random()},
					function(data){
						DataArray = data.split("|||");
						var a='';
						for (var i = 0; i<DataArray.length-1; i++) {
							att=DataArray[i].split("||");
							id=att[0];
							cla=att[2];
							a+='<option value="'+id+'||'+cla+'">'+att[1]+((cla=='1')?' ->':'')+'</option>';
						}
						
					$(whos).next().removeAttr('disabled').html('<option value="" selected="selected"></option>'+a).nextAll().html('');
					tonext($(whos).next());
					}
				)
			} else {
				$(whos).nextAll().html('').attr('disabled','true');
			};
		}
	)
};
$().ready(function() {
	tonext('#c1');
});
</script>
